﻿using System;
using System.Linq.Expressions;
using Domain.Core.Specification;
using Domain.MainModule.Entities;

namespace Domain.MainModule.Phones
{
    public class PhoneIdSpecification : Specification<Phone>
    {
        #region public properties

        public Guid PhoneId
        {
            get;
            set;
        }

        #endregion

        #region constructor

        public PhoneIdSpecification(Guid phoneId)
        {
            this.PhoneId = phoneId;
        }

        #endregion

        #region public methods

        public override Expression<Func<Phone, bool>> SatisfiedBy()
        {
            Specification<Phone> spec = new TrueSpecification<Phone>();
            spec &= new DirectSpecification<Phone>(c => c.PhoneId == this.PhoneId);

            return spec.SatisfiedBy();
        }

        #endregion
    }
}
